import Vue from 'vue';
import VueRouter from 'vue-router';
import store from '@/store';
import routes from './routes';
import { isWeChat,WeChat } from '@/utils/wechat';

Vue.use(VueRouter)

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    scrollBehavior: () => ({ y: 0 }),
    routes
})


router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    
    //微信环境处理
    if(isWeChat()) {
        WeChat(to.query)
    }

    next()
});

router.afterEach(() => {


});


export default router;